import java.util.Scanner;

public class Main {
    //if语句
    public static void main1(String[] args) {
        int a = 10;
        if(a > 5) {
            System.out.println("hh");
        }else {
            System.out.println("tt");
        }
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字");
        int i = scanner.nextInt();

        if (i % 2 == 0) {
            System.out.println(i + "为偶数");
        }else {
            System.out.println(i + "为奇数");
        }
    }

    //if if-else语句
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a  = scanner.nextInt();

        if (a > 10) {
            System.out.println(a);
        }else if (a > 5) {
            System.out.println("HH");
        }else {
            System.out.println("NO");
        }
    }

    //判断是否是闰年
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int year = scanner.nextInt();

        if(year % 100 == 0) {
            if(year % 400 == 0) {
                System.out.println(year + "是闰年");
            }else {
                System.out.println(year + "不是闰年");
            }
        }else {
            if(year % 4 == 0){
                System.out.println(year + "是闰年");
            }else {
                System.out.println(year + "不是闰年");
            }
        }
    }

    //switch 语句
    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        switch (a) {
            case 1:
                System.out.println("今天是星期一");
                break;
            case 2:
                System.out.println("今天是星期二");
                break;
            case 3:
                System.out.println("今天是星期三");
                break;
            case 4:
                System.out.println("今天是星期四");
                break;
            case 5:
                System.out.println("今天是星期五");
                break;
            case 6, 7:
                System.out.println("今天是休息日");
                break;
            default:
                System.out.println("输入错误");
                break;
        }
    }

    //循环结构
    //while 循环
    public static void main6(String[] args) {
        int i = 0;
        while(i <= 10) {
            System.out.println(i);
            i++;
        }
    }

    //计算1到100的和
    public static void main7(String[] args) {
        int i = 0;
        int sum = 0;
        while(i <= 100) {
            sum += i;
            i++;
        }
        System.out.println(sum);
    }

    //计算5的阶乘
    public static void main8(String[] args) {
        int i = 1;
        int sum = 1;
        while(i <= 5) {
            sum *= i;
            i++;
        }
        System.out.println(sum);
    }

    //计算1! + 2! + 3! + 4! + 5!
    public static void main9(String[] args) {
        int i;
        int sum;
        int n = 1;
        int all = 0;
        while (n <= 5) {
            i = 1;
            sum = 1;
            while(i <= n) {
                sum *= i;
                i++;
            }
            all += sum;
            n++;
        }
        System.out.println(all);
    }

    //break
    //找到 100 - 200 中第一个 3 的倍数
    public static void main10(String[] args) {
        int num = 100;
        while (num <= 200) {
            if(num % 3 == 0) {
                System.out.println("找到了的一个3的倍数的数：" + num);
                break;
            }
            num++;
        }
    }

    //continue / continue 的功能是跳过这次循环, 立即进入下次循环.
    //找到 100 - 200 中所有 3 的倍数
    public static void main11(String[] args) {
        int n = 100;
        while (n <= 200) {
            if(n % 3 != 0) {
                n++; // 这里的 ++ 不要忘记! 否则会死循环
                continue;
            }
            System.out.println(n);
            n++;
        }
    }

    //for 循环
    //计算5的阶乘
    public static void main12(String[] args) {
        int i  = 0;
        int sum = 1;
        for(i = 1; i <= 5; i++) {
            sum *= i;
        }
        System.out.println(sum);
    }

    //1! + 2! + 3! + 4! + 5!
    public static void main13(String[] args) {
        int i = 0;
        int sum = 0;
        for(i = 1; i <= 5; i++) {
            int tmp = 1;
            for(int j = 1; j <= i; j++) {
                tmp *= j;
            }
            sum += tmp;
        }
        System.out.println(sum);
    }

    //do while
    //计算 1-10
    public static void main14(String[] args) {
        int i = 1;
        do {
            System.out.println(i);
            i++;
        }while(i <= 10);
    }

    //输入Scanner
    public static void main15(String[] args) {
        Scanner scanner = new Scanner(System.in);

        //nextline() 和 next()
        //nextLine()方法是读取一整行，以一个回车符作为结束标记停止扫描
        //next() / nextInt() / nextDouble()等方法是，读取到第一个结束符【空格、回车、Tab键】作为结束标记停止扫描

        System.out.println("nextLine()方法输入:");
        String s1 = scanner.nextLine();
        System.out.println("next()方法输入:");
        String s2 = scanner.next();
        System.out.println("nextLine()结果：" + s1 + "\nnextLine()结果：" + s2);
    }

}